package com.k.note;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.http.RequestQueue;
import com.http.callback.RequestCallBack;
import com.http.method.JsonRequest;
import com.http.method.Request;
import com.viewplug.listView.RefreshToSwapListView;

import java.util.ArrayList;
import java.util.List;

import doc.User;

public class MainActivity extends Activity {
    //    @BindView(id = R.id.main_notelist)
//    RefreshToSwapListView main_list;

    RefreshToSwapListView listView;
    List<Integer> data = new ArrayList<Integer>();
    private TextView textView3,textView4;
    private ProgressBar progressBar;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
        String url = "http://112.126.65.106/all_column.jspx?start=0&count=10";
        final Request<User> request = new JsonRequest<User>(url,User.class,new RequestCallBack<User>() {
            @Override
            public void success(Object o) {

                Log.d("success","log");
            }
            @Override
            public void error(int errorCode, String message, Exception e) {
                Log.d("error","log");
            }



        });
        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RequestQueue.getInstance().addRequest(request);
            }
        });
       // finish();
        // windowManager should not be null
//        setContentView(R.layout.activity_main);
//        textView4 = (TextView) findViewById(R.id.textView4);
//        textView3 = (TextView) findViewById(R.id.textView3);
//        progressBar = (ProgressBar) findViewById(R.id.progressBar);
//        initView();
//        final File file = getCacheDir();
//        Log.e("file_dir",file.getAbsolutePath());
//        final DownFileManager downFileManager  = new DownFileManager();
//        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
////                MainActivity.this.startActivity(new Intent(MainActivity.this, MainActivity2.class));
//
//                String url="http://lx.cdn.baidupcs.com/file/216139e91db339385f2dd2249d77fbcb?bkt=p2-nj-931&xcode=b933c28b75a04b3979fee492aca1784b04d97d01a72d20aab23b1ad4a966d4fe&fid=1243967180-250528-772177764677996&time=1418277734&sign=FDTAXERLB-DCb740ccc5511e5e8fedcff06b081203-9AvA%2BMTavaT4030dPlcYOHwXR2A%3D&to=cb&fm=Nan,B,T,t&sta_dx=14&sta_cs=84&sta_ft=pdf&sta_ct=5&newver=1&newfm=1&flow_ver=3&sl=81723464&expires=8h&rt=pr&r=745582595&mlogid=1007185081&vuk=1243967180&vbdid=1126045077&fin=MySQL_5.5%E4%B8%AD%E6%96%87%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8C.pdf&fn=MySQL_5.5%E4%B8%AD%E6%96%87%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8C.pdf";
//                final long start = System.currentTimeMillis();
//                downFileManager.setSplite(3);
//                downFileManager.startDownFile(url,file,new RequestCallBack() {
//                    @Override
//                    public void start(int size) {
//                        super.start(size);
//                        progressBar.setMax(size);
//                    }
//
//                    @Override
//                    public void success() {
//                        Log.e("message","success");
//                        long end = System.currentTimeMillis();
//                        Log.e("message",""+(end-start));
//                    }
//
//                    @Override
//                    public void process(int total, int now_count, long speed, long leave_time) {
//                        super.process(total, now_count,speed, leave_time);
//                        long sp = speed/1000;
//                        progressBar.setProgress(now_count);
//                        textView3.setText(sp + "kb");
//                        leave_time=leave_time/1000;
//                        textView4.setText(leave_time+"s");
//                        //Log.e("process",total+"-"+now_count+'-'+sp+"kb");
//                    }
//                });
//            }
//        });
//        findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
    }


    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e("MainActivity", "onStart");

    }

    void initView() {
//        listView = (RefreshToSwapListView) findViewById(R.id.list_items);
//        for (int i = 0;i<100;i++)
//        {
//            data.add(i);
//        }
//        myAdapter = new MyAdapter();
//        listView.setAdapter(myAdapter);

    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("MainActivity", "onStop");

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("MainActivity", "onDestroy");
    }
}
